package com.yunfangdata.service.impl;


import com.yunfangdata.domain.BigCustomer;
import com.yunfangdata.mapper.BigCustomerMapper;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.service.IBigCustomerService;
import com.yunfangdata.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BigCustomerServiceImpl implements IBigCustomerService{
    
    @Autowired
    private BigCustomerMapper mapper;

    @Override
    public void save(BigCustomer entity) {

        mapper.insert(entity);

    }

    @Override
    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(BigCustomer entity) {
        mapper.updateByPrimaryKey(entity);
    }

    @Override
    public BigCustomer get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BigCustomer> list() {
        return mapper.selectAll();
    }

    public PageResult query(QueryObject qo) {
       int  total = mapper.queryForCount(qo);
        if (total==0){
            return new PageResult();   
        }
        List<BigCustomer> rows = mapper.queryForList(qo);

        return new PageResult(total,rows);
    }

    public void changeFollow(Long id) {
        mapper.changeFollow(id);
    }

    public void changeState(Long id) {
        mapper.changeState(id);
    }

}

